package com.yeyks.dal.dao;

import com.yeyks.dal.domain.AccountInfo;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface AccountInfoMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(AccountInfo record);

    AccountInfo selectByPrimaryKey(Integer id);

    List<AccountInfo> selectAll();

    int updateByPrimaryKey(AccountInfo record);

    List<AccountInfo> selectUsePhonePwd(@Param("phone") String phone, @Param("password") String password);

    List<AccountInfo> selectUseUsernamePwd(@Param("username") String username, @Param("password") String password);

    List<AccountInfo> selectByPhoneOrUsername(@Param("phone") String phone, @Param("username") String username);

    AccountInfo selectByUsername(@Param("username") String username);

    List<AccountInfo> selectByType(@Param("type") Integer type);

    int modifyPassword(@Param("phone") String phone, @Param("username") String username, @Param("password") String password);

    int modifyPasswordById(@Param("id") Integer id, @Param("password") String password);

    AccountInfo selectUsePhone(@Param("phone") String phone);

    int deleteByPhone(@Param("phone") String phone);

    int insertReturnId(AccountInfo record);

    AccountInfo selectByUniques(AccountInfo accountInfo);

    int clear();

    int deleteByType(@Param("type") Integer type);

    int updateExtraInfoById(@Param("id") Integer id, @Param("extraInfo") String extraInfo);

    int updateParentIdAndTypeById(@Param("id") Integer id, @Param("parentId") Integer parentId, @Param("type") Integer type);

    List<AccountInfo> selectChildByValidKeyword(@Param("id") Integer id, @Param("valid") Boolean valid, @Param("keyword") String keyword,
                                                @Param("area") String area, @Param("offset") Integer offset, @Param("maxrow") Integer maxrow);

    int selectChildByValidKeywordCount(@Param("id") Integer id, @Param("valid") Boolean valid, @Param("keyword") String keyword, @Param("area") String area);

    List<AccountInfo> selectByTypeValidKeyword(@Param("type") Integer type, @Param("valid") Boolean valid, @Param("keyword") String keyword,
                                               @Param("area") String area, @Param("offset") Integer offset, @Param("maxrow") Integer maxrow);

    int selectByTypeValidKeywordCount(@Param("type") Integer type, @Param("valid") Boolean valid, @Param("keyword") String keyword, @Param("area") String area);

    List<AccountInfo> selectChildren(@Param("ids") List<Integer> ids);

    int countOfChildren(@Param("id") Integer id, @Param("dtStart") Date dtStart, @Param("dtEnd") Date dtEnd);

    int countOfGrandchildren(@Param("id") Integer id, @Param("dtStart") Date dtStart, @Param("dtEnd") Date dtEnd);

    int countOfGrandchildchildren(@Param("id") Integer id, @Param("dtStart") Date dtStart, @Param("dtEnd") Date dtEnd);

    int setPrecentage(@Param("admin") Integer admin, @Param("branch") Integer branch, @Param("city") Integer city);

    List<Map> getPrecentage();

    AccountInfo selectOperatorByRoomId(@Param("id") Integer id);

    Integer selectUserIdByAreaAndType(@Param("cityName") String cityName, @Param("type") Integer type);

    void updateParentId(@Param("cityName") String cityName, @Param("type") Integer type, @Param("id") Integer id);

    List<AccountInfo> cityAgentList(Map<String, Object> map);

    Integer cityAgentListCount(Map<String, Object> map);

    List<AccountInfo> testCreateCityAgent();

    AccountInfo selectAccountByArea(Map<String, Object> map);

    List<AccountInfo> selectTwoChildren(@Param("id") Integer id);

    AccountInfo selectUseUsernamePwdV2(@Param("username") String username, @Param("password") String password);

    /**
     * 通过酒店id获取酒店的所有上级
     *
     * @param id
     * @return
     */
    List<Integer> selectAllParentId(Integer id);

    List<AccountInfo> selectByOperatorIds(@Param("operatorIds") List<Integer> operatorIds);
}